const router = require("koa-router")();
const UserModel = require("../../models/user")
router.post("/m1/doLogin",async ctx=>{
    var {userName,pwd} = ctx.request.body;
    // console.log(userName,pwd);
    var res = await UserModel.find({userName,pwd:Number(pwd)}) 
    // console.log(res)
    if(res.length){
        ctx.cookies.set("login",true)
        ctx.redirect("/m1")
    }else{
        ctx.body = "<script>alert('用户名或密码错误');location.href='/login'</script>"
    }
})
module.exports = router;